package com.example.demo.test1.controller;

import com.example.demo.utils.AsyncTest;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.javassist.NotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @ClassName TestController
 * @Author l42142
 * @Date 2021/3/5 14:56
 * @Description TODO
 * @Version 1.0
 **/
@RestController
@Api(tags = "测试")
@RequestMapping("/test/")
public class TestController {
    @Autowired
    AsyncTest asyncTest;

    @RequestMapping("/test")
    @ApiOperation("测试")
    public String test(HttpServletResponse response){

        long start = System.currentTimeMillis();
        System.out.println("test start = " + start);
        asyncTest.test1(asyncTest);
        asyncTest.test2(asyncTest);
        long end = System.currentTimeMillis();
        System.out.println("test end = " + end);
        System.out.println("test = " + (end - start));
        String[] elementData = new String[]{"1", "2", "3", "4"};
        System.arraycopy(elementData, 2, elementData, 3, 2);
//             {"3", "4"}        // 2(srcPos)  ~ 2+2-1(srcPos+length-1)
//        {"1", "2", "3", "4"}// 1(destPos) ~ 1+2-1(destPos+length-1)
        System.out.println(Arrays.toString(elementData));

        return "success";
    }
}
